/*
 * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
 * <p>
 * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.gnu.org/licenses/lgpl.html
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.gitee.yannzh.rune.support.crud.query;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

/**
 * @author: yann
 * @description: 查询类型枚举  https://baomidou.com/pages/10c804/
 * @date: 2024-01-28
 */
@Getter
@RequiredArgsConstructor
public enum Condition {
    /**
     * 等于 =
     * 例: eq("name", "老王")--->name = '老王'
     */
    EQ("eq", "name = '老王'"),

    /**
     * 不等于 <>
     * 例: ne("name", "老王")--->name <> '老王'
     */
    NE("ne", "!="),

    /**
     * 大于 >
     * 例: gt("age", 18)--->age > 18
     */
    GT("gt", ">"),

    /**
     * 大于等于 >=
     * 例: ge("age", 18)--->age >= 18
     */
    GE("ge", ">="),

    /**
     * 小于 <
     * 例: lt("age", 18)--->age < 18
     */
    LT("lt", "<"),

    /**
     * 小于等于 <=
     * 例: le("age", 18)--->age <= 18
     */
    LE("le", "<="),

    /**
     * BETWEEN 值1 AND 值2
     * 例: between("age", 18, 30)--->age between 18 and 30
     */
    BETWEEN("between", "between"),

    /**
     * NOT BETWEEN 值1 AND 值2
     * 例: notBetween("age", 18, 30)--->age not between 18 and 30
     */
    NOT_BETWEEN("notBetween", "notBetween"),

    /**
     * LIKE '%值%'
     * 例: like("name", "王")--->name like '%王%'
     */
    LIKE("like", "like %xxx%"),

    /**
     * NOT LIKE '%值%'
     * 例: notLike("name", "王")--->name not like '%王%'
     */
    NOT_LIKE("notLike", "not like %xxx%"),


    /**
     * LIKE '%值'
     * 例: likeLeft("name", "王")--->name like '%王'
     */
    LIKE_LEFT("likeLeft", "like '%xx'"),

    /**
     * LIKE '值%'
     * 例: likeRight("name", "王")--->name like '王%'
     */
    LIKE_RIGHT("likeRight", "like 'xx%'"),


    /**
     * NOT LIKE '%值'
     * 例: notLikeLeft("name", "王")--->name not like '%王'
     */
    NOT_LIKE_LEFT("notLikeLeft", "not like '%xx'"),

    /**
     * NOT LIKE '值%'
     * 例: notLikeRight("name", "王")--->name not like '王%'
     */
    NOT_LIKE_RIGHT("notLikeRight", "not like 'xx%'"),


    /**
     * 字段 IS NULL
     * 例: isNull("name")--->name is null
     */
    IS_NULL("isNull", "xxx is null"),

    /**
     * 字段 IS NOT NULL
     * 例: isNotNull("name")--->name is not null
     */
    IS_NOT_NULL("isNotNull", "xxx is not null"),


    /**
     * 字段 IN (value.get(0), value.get(1), ...)
     * 例: in("age",{1,2,3})--->age in (1,2,3)
     */
    IN("in", "in (x,y,c)"),


    /**
     * 字段 NOT IN (value.get(0), value.get(1), ...)
     * 例: notIn("age",{1,2,3})--->age not in (1,2,3)
     */
    NOT_IN("notIn", "not in (x,y,c)"),


    /**
     * 字段 IN ( sql语句 )
     * 例: inSql("age", "1,2,3,4,5,6")--->age in (1,2,3,4,5,6)
     * 例: inSql("id", "select id from table where id < 3")--->id in (select id from table where id < 3)
     */
    IN_SQL("inSql", "in (x,y,c)"),


    /**
     * 字段 NOT IN ( sql语句 )
     * 例: notInSql("age", "1,2,3,4,5,6")--->age not in (1,2,3,4,5,6)
     * 例: notInSql("id", "select id from table where id < 3")--->id not in (select id from table where id < 3)
     */
    NOT_IN_SQL("notInSql", "not in (x,y,c)")



    ;


    private final String name;
    private final String description;
}
